<template>
	<view class="bg-white u-padding-20">
		<u-navbar  title="课程列表" :autoBack="true" safeAreaInsetTop fixed placeholder />
		<view class="u-demo-area">
			<u-cell-group>
				<u-cell v-for="(item,index) in list" :key="index"  center size="large"
					:is-link="true" index="index" @click="showDetail(item.id)" 
					:title-style="{'width': '75%'}" :arrow="true">
					<view slot="title" class="line-height-view">{{item.name}}</view>
					<view slot="label" class="line-height-view">有效期{{item.expireMonths}}个月（{{item.lessonCount}}次 ）</view>
					<!-- <view slot="label" class="line-height-view">{{item.info}} </view> -->
					<view slot="value">￥{{item.price}}</view>
				</u-cell>
			</u-cell-group>
			<view class="u-padding-30 bg-white" v-if="list.length == 0" >
				<u-empty mode="list" text="暂无记录"></u-empty>
			</view>
		</view>
	</view>
</template>
<script>
	import paginateMix from "@/mixins/paginateMixins.js"
	import request from '@/utils/request'
	export default {
		mixins: [paginateMix],
		data() {
			return {
				checked: false,
				list: [],
			}
		},
		onLoad() {
			this.handleReq()
		},
		methods: {
			handleReq() {
				request({url:'/erp/course/page',data:{page: this.pageData.page}}).then(res => {
					if(!this.$common.handleResponseMsg(res)) return;
					this.list = this.list.concat(res.data.list)
					this.pageData.page = parseInt(res.page);
					this.pageData.lastPage = parseInt(res.pageCount);
				});
			},
			showDetail(id) {
				uni.navigateTo({
					url: `/pages/course/detail?courseId=${id}`
				});
			},
			clickRight() {
				this.list = [];
				this.pageData.page = 1
				this.handleReq()
			},
			clickLeft() {
				uni.switchTab({
					url: '/pages/index/index'
				});
			}
		}
	}
</script>
<style lang="scss" scoped>
	.line-height-view {
		line-height:30px;
		height: 30px;
	}
</style>
